﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic; 

namespace Reconciliation.Web.Users_Control
{
    public partial class PersonnelView : System.Web.UI.UserControl
    {
        public string PackedDateTime;
        public string DeliveredDateTime;
        public string FLMDateTime;
        public string ReturnedDateTime;
        public string UnPackedDateTime;

        protected void Page_Load(object sender, EventArgs e)
        {
            string s = Request.QueryString["OrderID"];
            int OrderID = int.Parse(s);

            List<Domain.OrderCycle> domainOrderCycleList = new List<Reconciliation.Domain.OrderCycle>();
            domainOrderCycleList = Services.Services.GetOrderCycle(OrderID);

            for (int i = 0; i < domainOrderCycleList.Count; i++)
            {
                if (domainOrderCycleList[i].Status == "Packed")
                {
                    PackedDateTime = BasePage.FormatDate(domainOrderCycleList[i].DateTime) + " | " + BasePage.FormatTime(domainOrderCycleList[i].DateTime);
                    RepeaterPacked.DataSource = domainOrderCycleList[i].OrderCycleEmployeeList;
                    RepeaterPacked.DataBind();
                }
                if (domainOrderCycleList[i].Status == "Delivered")
                {
                    DeliveredDateTime = BasePage.FormatDate(domainOrderCycleList[i].DateTime) + " | " + BasePage.FormatTime(domainOrderCycleList[i].DateTime);
                    RepeaterDelivered.DataSource = domainOrderCycleList[i].OrderCycleEmployeeList;
                    RepeaterDelivered.DataBind();
                }
                if (domainOrderCycleList[i].Status == "FLM")
                {
                    FLMDateTime = BasePage.FormatDate(domainOrderCycleList[i].DateTime) + " | " + BasePage.FormatTime(domainOrderCycleList[i].DateTime);
                    RepeaterFLM.DataSource = domainOrderCycleList[i].OrderCycleEmployeeList;
                    RepeaterFLM.DataBind();

                    //Response.Write(domainOrderCycleList[i].DateTime.ToString("dd.MM.yy | hh.mm tt"));                   
                }
                if (domainOrderCycleList[i].Status == "Returned")
                {
                    ReturnedDateTime = BasePage.FormatDate(domainOrderCycleList[i].DateTime) + " | " + BasePage.FormatTime(domainOrderCycleList[i].DateTime);
                    RepeaterReturned.DataSource = domainOrderCycleList[i].OrderCycleEmployeeList;
                    RepeaterReturned.DataBind();
                }
                if (domainOrderCycleList[i].Status == "UnPacked")
                {
                    UnPackedDateTime = BasePage.FormatDate(domainOrderCycleList[i].DateTime) + " | " + BasePage.FormatTime(domainOrderCycleList[i].DateTime);
                    RepeaterUnPacked.DataSource = domainOrderCycleList[i].OrderCycleEmployeeList;
                    RepeaterUnPacked.DataBind();
                }
            }
        }
    }
}